<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: id
  Date: 2021/1/8
  Time: 16:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page  isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../util/makerAndenterGoodAndselect1.jsp"%>
<html>
<head>
    <title>ADD entergoods</title>
    <style type="text/css">
        #add{
            width: 1288px;
            height:1000px;
            position: absolute;
            top: 60px;
            left: 83px;
        }
        input{
            text-align: center;
        }
        .fr{
            width: 400px;
            height: 300px;
            position: relative;
            left: 480px;
            top: 50px;
        }
        span{
            color: cadetblue;
        }
    </style>
    <script type="text/javascript" src="../../../static/jquery-3.4.1.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#add").hover(function () {
                    $("#d3").hide()
                    $("#xs").hide()
                    $("#d2").hide()
                    $("#d4").hide()
                }
            )


            /*效验*/
            var fl=true;
            var re =/[\u4e00-\u9fa5]/;  //中文
            var reg = /^[0-9]+.?[0-9]*$/;           //数字
            var reg2 = /^[A-Za-z]+$/ //字母
            var reg3 = /^(?!\d+$)(?![a-zA-Z]+$)[a-zA-Z\d]+$/ //;//字母和数字

            var good=$("#goodname2").val();
            var num=$("#num").val();
            var money=$("#money").val();
            var danwei=$("#danwei").val();
            if(good==null || good==""||num==null || num==""||money==null || money==""||danwei==null || danwei==""){
                $("#s1").html("?")
                $("#s2").html("?")
                $("#s3").html("?")
                $("#s4").html("?")
                fl=false;
            }else {
                fl=true;
            }


            $("#goodname2").blur(function () {
                if($("#goodname2").val()==null ||$("#goodname2").val()==""){
                    $("#s1").html("商品名称不能为空")
                    fl=false;
                }else if(reg.test($("#goodname2").val())){
                    $("#s1").html("不得为数字!")
                    fl=false;
                } else {
                    $("#s1").html("√")
                    fl=true;
                }
            })


            $("#num").blur(function () {
                if($("#num").val()==null ||$("#num").val()==""){
                    $("#s2").html("请填写商品个数")
                    fl=false;
                }else if(re.test($("#num").val())){
                    $("#s2").html("商品个数不得为中文!")
                    fl=false;
                }else if(reg2.test($("#num").val())) {
                    $("#s2").html("商品个数不得为字母!")
                    fl = false;
                }else if(reg3.test($("#num").val())){
                    $("#s2").html("不得为字母或字母!")
                    fl = false;
                }else {
                    $("#s2").html("√")
                    fl=true;
                }
            })


            $("#money").blur(function () {
                if($("#money").val()==null ||$("#money").val()==""){
                    $("#s3").html("请填写商品价格")
                    fl=false;
                }else if(re.test($("#money").val())){
                    $("#s3").html("商品价格不得为中文!")
                    fl=false;
                }else if(reg2.test($("#money").val())){
                    $("#s3").html("商品价格不得为字母!")
                    fl=false;
                }else if(reg3.test($("#money").val())){
                    $("#s3").html("不得为字母或字母!")
                    fl = false;
                }
                else {
                    $("#s3").html("√")
                    fl=true;
                }
            })


            $("#danwei").blur(function () {
                if($("#danwei").val()==null ||$("#danwei").val()==""){
                    $("#s4").html("商品单位必须为中文!")
                    fl=false;
                }else if(re.test($("#danwei").val())){
                    $("#s4").html("√");
                    fl=true;
                } else {
                    $("#s4").html("商品单位必须为中文!")
                    fl=false;
                }
            })



            /*表单验证*/
            $("Form").submit(function () {
                return fl;
            })
        })
    </script>
</head>
<body>

<div id="add">
    <div class="fr">
        <form action="${pageContext.request.contextPath}/enterGoods/addEnterGoods">
            <input type="hidden" value="${egid}" name="egid">
            <input type="hidden" value="${rid}" name="rid">
            <input type="hidden" value="${goodstyle}" name="goodstyle">
            <span>商品类型:</span>
            <select  style="width: 170px;height: 30px;border-radius: 6px" disabled>
               <c:if test="${goodstyle==1}">
                   <option >电子</option>
               </c:if>
                <c:if test="${goodstyle==2}">
                    <option >食品</option>
                </c:if>
                <c:if test="${goodstyle==3}">
                    <option >生活</option>
                </c:if>

            </select>

            <br><br>

            <span>商品名称</span>&nbsp;
            <select  style="width: 170px;height: 30px;border-radius: 6px" name="goodname2" id="goodname2">
                <c:forEach items="${lack}" var="goods">
                    <option value="${goods.goodname3}">${goods.goodname3}(数量${goods.num3})(单价${goods.money3})</option>
                </c:forEach>
            </select>
            <span id="s1" style="color: red"></span>
            <br><br>

            <span>商品个数</span>&nbsp;
            <input type="text" name="num" style="width: 170px;height: 30px;border-radius: 6px" id="num">
            <span id="s2" style="color: red"></span>
            <br><br>

            <span>单价</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="text" name="money" style="width: 170px;height: 30px;border-radius: 6px" id="money">
            <span id="s3" style="color: red"></span>
            <br><br>

            <span>单位</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="text" name="danwei" style="width: 170px;height: 30px;border-radius: 6px" id="danwei">
            <span id="s4" style="color: red"></span>
            <br><br>

            <span>入仓之库:</span>&nbsp;
            <select  style="width: 170px;height: 30px;border-radius: 6px" disabled>
              <c:if test="${rid==1}">
                  <option value="${rid}">东仓</option>
              </c:if>
                <c:if test="${rid==2}">
                    <option value="${rid}">西仓</option>
                </c:if>
                <c:if test="${rid==3}">
                    <option value="${rid}">南仓</option>
                </c:if>
                <c:if test="${rid==4}">
                    <option value="${rid}">北仓</option>
                </c:if>
            </select>
            <br><br>


            &nbsp;&nbsp;&nbsp;&nbsp;
            <input type="submit" value="Add to" style="width: 170px;height: 30px;border-radius: 6px">
        </form>
    </div>
</div>




</body>
</html>
